package cn.bsb.controller.backstage;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.github.pagehelper.PageInfo;

import cn.bsb.pojo.DevUser;
import cn.bsb.service.backstage.UserListService;

@Controller
@RequestMapping("/user")
public class UserListController {

	@Autowired
	private UserListService service;

	private Logger logger = Logger.getLogger(UserListController.class);

	@RequestMapping("/index")
	public String index(@RequestParam(value = "pageNumber", required = false, defaultValue = "1") int pageNumber,
			@RequestParam(value = "userCode", required = false) String userCode, Model mod){
		logger.info("===================================="+userCode);
		PageInfo<DevUser> userlist = service.getDevUserList(userCode, pageNumber, 10);
		List<DevUser> userList = userlist.getList();
		mod.addAttribute("userList", userList);
		mod.addAttribute("page",userlist);
		if(userCode!=null&&!userCode.equals("")) {
			mod.addAttribute("userCode",userCode);
		}
		return "backstage/userlist";
	}

}
